package com.zh.controller.upload;

import cn.dev33.satoken.annotation.SaIgnore;
import com.zh.pojo.dto.UploadDto;
import com.zh.result.JSONResult;
import com.zh.service.IUploadService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;

@RestController
@RequestMapping("/upload")
public class UploadController {

    @Autowired
    private IUploadService uploadService;

    @Operation( summary= "小程序微信司机注册",description = "小程序微信司机注册接口")
    @Parameter(name = "driver",description = "注册的对象",required = true)
    // 此接口加上了 @SaIgnore 可以游客访问
    @PostMapping("/cos")
    public JSONResult cosUpload(MultipartFile file,   UploadDto uploadDto){
       String imgUrl =  uploadService.cosUpload(file, uploadDto);
        return JSONResult.success(imgUrl);
    }
}
